package com.demo.springBootDemo06.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;

@Configuration
public class AppConfig {

//	@Autowired
//	DataSourceProperties dataSourceProperties;

	@Bean(initMethod="init", destroyMethod="close")
	@ConfigurationProperties(prefix = "spring.datasource")
	public DataSource dataSource() {
		DruidDataSource datasource = new DruidDataSource();
//		datasource.setUrl(dataSourceProperties.getUrl());
//		datasource.setUsername(dataSourceProperties.getUsername());
//		datasource.setPassword(dataSourceProperties.getPassword());
//		datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
		return datasource;
	}
}
